local sk__xiecui = fk.CreateSkill {

  name = "sk__xiecui",

  tags = {  },

}



sk__xiecui:addEffect(fk.DamageCaused, {
  name = "sk__xiecui",
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(sk__xiecui.name) and target and not target.dead and target == player.room.current and
      #player.room.logic:getActualDamageEvents(2, function(e) return e.data.from == target end) == 0 and
      #player:getCardIds("he") > 1
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local success, dat = room:askForUseActiveSkill(player, "sk__xiecui_active", "#sk__xiecui-invoke::"..target.id, true)
    if success then
      event:setCostData(self, dat)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:doIndicate(player.id, {target.id})
    room:throwCard(event:getCostData(self).cards, sk__xiecui.name, player, player)
    local n = #room.logic:getEventsOfScope(GameEvent.UseCard, 999, function(e)
      local use = e.data
      return use and use.from == target
    end, Player.HistoryTurn)
    if event:getCostData(self).interaction == "damage+1" then
      data.damage = data.damage + 1
      if not target.dead and n > 0 then
        target:drawCards(n, sk__xiecui.name)
      end
    else
      data.damage = data.damage - 1
      if not target.dead and n > 0 then
        room:askForDiscard(target, n, n, true, sk__xiecui.name, false)
      end
    end
  end,
})

return sk__xiecui